package my.example.samplegridview.modal;

import java.util.Vector;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

public class product_discount {
	public static final String Table = "o2s_product_discount";
    public static final Uri    CONTENT_URI = Uri.parse("content://o2s.contentprovider.datacontentprovider/product_discount");
    public static final String SQLCREATE = "CREATE TABLE 'o2s_product_discount' ( " +
    										"'product_discount_id' INTEGER NOT NULL PRIMARY KEY, " +
    										"'product_id' int(11) NOT NULL , " +
    										"'customer_group_id' int(11) NOT NULL , " +
    										"'quantity' int(4) NOT NULL DEFAULT '0' , " +
    										"'priority' int(5) NOT NULL DEFAULT '1' , " +
    										"'price' decimal(15 ,4) NOT NULL DEFAULT '0.0000' , " +
    										"'date_start' date NOT NULL DEFAULT '0000-00-00' , " +
    										"'date_end' date NOT NULL DEFAULT '0000-00-00' );";
    
    private String product_discount_id;
    private String product_id;
    private String customer_group_id;
    private String quantity;
    private String priority;
    private String price;
    private String date_start;
    private String date_end;
    
    public static Vector<product> SelectDiscountProduct(Context context){
    	Cursor c = context.getContentResolver().query(CONTENT_URI, null, "date_start < datetime('now','localtime') AND datetime('now','localtime') < date_end", null, null);
    	Vector<product> products = new Vector<product>();
    	while(c.moveToNext()){
    		product p = new product(context,c.getString(1));
			p.setPrice(String.valueOf(c.getDouble(5)));
			products.add(p);
		}
		c.close();
		return products;
    }
    
	public String getProduct_discount_id() {
		return product_discount_id;
	}
	public void setProduct_discount_id(String product_discount_id) {
		this.product_discount_id = product_discount_id;
	}
	public String getProduct_id() {
		return product_id;
	}
	public void setProduct_id(String product_id) {
		this.product_id = product_id;
	}
	public String getCustomer_group_id() {
		return customer_group_id;
	}
	public void setCustomer_group_id(String customer_group_id) {
		this.customer_group_id = customer_group_id;
	}
	public String getQuantity() {
		return quantity;
	}
	public void setQuantity(String quantity) {
		this.quantity = quantity;
	}
	public String getPriority() {
		return priority;
	}
	public void setPriority(String priority) {
		this.priority = priority;
	}
	public String getPrice() {
		return price;
	}
	public void setPrice(String price) {
		this.price = price;
	}
	public String getDate_start() {
		return date_start;
	}
	public void setDate_start(String date_start) {
		this.date_start = date_start;
	}
	public String getDate_end() {
		return date_end;
	}
	public void setDate_end(String date_end) {
		this.date_end = date_end;
	}
    
    
}
